<template>
  <div class="clubPage">
    <div class="searchBox bgfff">
      <el-form
        :inline="true"
        :model="form"
        ref="formRef"
        class="demo-form-inline"
        size="small"
        label-position="right"
        label-width="100px"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="居住房源：" prop="clubName">
              <el-input v-model="form.clubName" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="居民姓名：" prop="name">
              <el-input v-model="form.name" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="居民手机号：" prop="mobile">
              <el-input v-model="form.mobile" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="人员标签：" prop="status">
              <el-input v-model="form.status" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="margin: 20px 0">
          <el-col :span="6">
            <el-form-item label="性别：" prop="clubName">
              <el-input v-model="form.clubName" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="政治面貌：" prop="name">
              <el-input v-model="form.name" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证件号码：" prop="mobile">
              <el-input v-model="form.mobile" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="人口属性：" prop="status">
              <el-input v-model="form.status" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="display: flex; justify-content: flex-end">
          <el-form-item>
            <el-button type="primary" size="small" @click="onSubmit"
              >查询</el-button
            >
            <el-button @click="resetForm('formRef')">重置</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
    <div class="tablesCard bgfff">
      <div class="tablesCardTop">
        <div>
          <el-button
            type="primary"
            size="small"
            @click="
              () => {
                addPeopleShow = true;
              }
            "
            >添加居民</el-button
          >
          <el-button type="primary" plain size="small">导入</el-button>
          <el-button type="primary" plain size="small">导出</el-button>
        </div>
        <el-button type="primary" size="small" @click="addScoreShow = true"
          >赋分</el-button
        >
      </div>
      <el-table
        v-if="type == 1"
        :data="tableData"
        border
        size="small"
        style="width: 100%"
      >
        <!-- height="580" -->
        <el-table-column prop="_code" label="序号" align="center" width="80">
        </el-table-column>
        <el-table-column prop="userName" label="姓名" align="center">
        </el-table-column>
        <el-table-column prop="nickName" label="昵称" align="center" />
        <el-table-column prop="mobile" label="手机号" align="center">
        </el-table-column>
        <el-table-column prop="idNo" label="证件号码" align="center" />
        <el-table-column prop="" label="性别" align="center">
          <template slot-scope="scope">
            {{ scope.row.sex == 1 ? "男" : "女" }}
          </template>
        </el-table-column>

        <el-table-column prop="score" label="人口属性" align="center" />
        <el-table-column prop="score" label="政治面貌" align="center" />
        <el-table-column prop="score" label="人员标签" align="center" />
        <el-table-column prop="score" label="认证类型" align="center" />

        <el-table-column
          fixed="right"
          prop=""
          label="操作"
          align="center"
          width="190"
        >
          <template slot-scope="scope">
            <div class="">
              <el-link type="warning">积分二维码</el-link>
              <el-divider direction="vertical"></el-divider>
              <el-link type="primary">查看</el-link>
              <el-divider direction="vertical"></el-divider>
              <el-link type="primary">编辑</el-link>
              <el-link type="danger" @click="onBtns(2, scope.row)"
                >迁出</el-link
              >
              <el-divider direction="vertical"></el-divider>
              <el-link type="danger" @click="onBtns(2, scope.row)"
                >添加标签</el-link
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-table
        v-else
        :data="tableData"
        border
        size="small"
        style="width: 100%"
      >
        <!-- height="580" -->
        <el-table-column prop="_code" label="序号" align="center" width="80">
        </el-table-column>
        <el-table-column prop="name" label="申请时间" align="center" />
        <el-table-column prop="name" label="申请社团" align="center">
        </el-table-column>
        <el-table-column prop="userName" label="社长姓名" align="center" />
        <el-table-column prop="userName" label="申请人" align="center" />
        <el-table-column prop="mobile" label="手机号" align="center" />

        <el-table-column prop="" label="所在小区" align="center" />
        <el-table-column prop="" label="居民房屋" align="center" />
        <el-table-column prop="" label="审核状态" align="center" />
        <el-table-column prop="" label="审核人" align="center" />
        <el-table-column
          fixed="right"
          prop=""
          label="操作"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <div class="operateBtns">
              <el-link type="primary" @click="onBtns(4, scope.row)"
                >审核</el-link
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageBlock">
        <el-pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          :current-page.sync="form.page"
          :page-size="form.limit"
          @size-change="
            (e) => {
              form.limit = e;
              getList();
            }
          "
          @current-change="
            (e) => {
              form.page = e;
              getList();
            }
          "
        >
        </el-pagination>
      </div>
    </div>
    <addPeople
      v-if="addPeopleShow"
      @handleClose="
        (val) => {
          addPeopleShow = false;
          if (val) getList();
        }
      "
      :dialogVisible="addPeopleShow"
    ></addPeople>
    <addScore
      v-if="addScoreShow"
      @handleClose="
        (val) => {
          addScoreShow = false;
          if (val) getList();
        }
      "
      :dialogVisible="addScoreShow"
    >
    </addScore>
  </div>
</template>

<script>
import { clubList, delClub } from "@/api/club.js";
import addPeople from "./common/addPeople.vue";
import addScore from "./common/addScore.vue";
export default {
  name: "",
  props: [""],

  data() {
    return {
      type: "1",
      form: {
        clubName: "",
        name: "",
        mobile: "",
        remarks: "",
      },
      tableData: [{}],
      total: 0,
      projectId: "",
      checkShow: false,
      radio: 1,

      addPeopleShow: false,
      addScoreShow: false,
      clubInfo: {},
      refuseShow: false,
    };
  },

  components: { addPeople, addScore },

  computed: {},

  beforeMount() {},

  mounted() {
    this.getList();
  },

  methods: {
    onSubmit() {
      this.getList();
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.getList();
    },
    getList() {
      clubList(this.form).then((res) => {
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.total = res.data.count;
        }
      });
    },
    onBtns(val, info) {
      this.clubInfo = info;
      if (val == 1) {
        //通过
        this.$refs[`popover-${info.id}`].doClose();
      } else if (val == 2) {
        //拒绝
        this.refuseShow = true;
        this.addPeople = true;
      } else if (val == 3) {
        //删除
        this.$refs[`popover-${info.id}`].doClose();
        delClub({ id: info.id }).then((res) => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: res.msg,
            });
            this.getList();
          }
        });
      } else if (val == 4) {
        //审核
        this.checkShow = true;
      }
    },

    handleClick() {
      this.form.page = 1;
      this.getList();
    },
    onRefuse(formName) {
      //拒绝
      this.$refs[formName].validate((valid) => {
        if (valid) {
        } else {
        }
      });
    },
  },

  watch: {},
};
</script>
<style lang='scss' scoped>
.clubPage {
  .searchBox {
    position: relative;
    margin-bottom: 14px;
    padding: 15px 24px;
    display: flex;
    flex-direction: column;
    .tabsBox {
      margin: 10px 0 20px;
      .el-tabs {
        display: flex;
        flex-direction: column;
        justify-content: center;
        .el-tabs__nav-wrap::after {
          background-color: rgba(0, 0, 0, 0);
        }
      }
    }
    /deep/.el-form-item {
      margin-bottom: 0;
      .el-input__inner {
        width: 300px;
      }
    }
    .addBtns {
      position: absolute;
      top: 15px;
      right: 24px;
    }
  }
  .tablesCard {
  }
}
</style>